import { FormItemRule } from "naive-ui";
const registerFormConfig: Record<string, any> = {
	isVertical: true,
	labelPlacement:'left',
	labelWidth: 80,
	formItems: [
		{
			field: "account",
			labelName: "账号",
			labelStyle: "fontSize:14px;",
			type: "Input",
			inputType: "text",
			inputWidth: "180px",
			placeholder: "请输入账号",
		},
		{
			field: "email",
			labelName: "邮箱",
			labelStyle: "fontSize:14px;",
			type: "Input",
			inputType: "email",
			inputWidth: "180px",
			placeholder: "请输入邮箱",
		},
		{
			field: "password",
			labelName: "密码",
			labelStyle: "fontSize:14px;",
			type: "Input",
			inputType: "password",
			inputWidth: "180px",
			show_password_on: "mousedown",
			placeholder: "请输入密码",
		},
		{
			field: "comfirPassword",
			labelName: "确认密码",
			labelStyle: "fontSize:14px;",
			type: "Input",
			inputType: "password",
			inputWidth: "180px",
			show_password_on: "mousedown",
			placeholder: "请确认密码",
		},
		{
			field: "code",
			labelName: "验证码",
			labelStyle: "fontSize:14px;",
			type: "Input",
			inputType: "text",
			inputWidth: "180px",
			placeholder: "请输入验证码",
		},
	],
	rules: {
		account: {
			required: true,
			trigger: ["input"],
			message: "注册账号不能为空",
			validator(rule: FormItemRule, value: string) {
				if (value.trim().length === 0) {
					return new Error("账号为空");
				}
				return true;
			},
		},
		email: {
			required: true,
			trigger: ["input"],
			message: "请输入正确的邮箱格式",
            validator(rule: FormItemRule, value: string) {
                const emailReg = /^\w+@[a-z0-9]+(\.[a-z]+){1,3}$/;
                
                if (!emailReg.test(value.trim())) {
                    
					return new Error("邮箱格式错误");
				}
				return true;
			},
		},
		password: {
			required: true,
			trigger: ["input"],
			message: "注册密码不能为空",
			validator(rule: FormItemRule, value: string) {
				if (value.trim().length === 0) {
					return new Error("密码为空");
				}
				return true;
			},
		},
		comfirPassword: {
			required: true,
			trigger: ["input"],
			message: "确认密码不能为空",
            validator(rule: FormItemRule, value: string) {
                
				if (value.trim().length === 0) {
					return new Error("确认密码为空");
				}
				return true;
			},
		},
		code: {
			required: true,
			trigger: ["input"],
			message: "验证码不能为空",
			validator(rule: FormItemRule, value: string) {
				if (value.trim().length === 0) {
					return new Error("验证码为空");
				}
				return true;
			},
		},
	},
};
export default registerFormConfig;
